# Contributor: Sean Summers <seansummers@gmail.com>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=tomcat-native
pkgver=1.2.33
pkgrel=0
pkgdesc="Native resources optional component for Apache Tomcat"
url="https://tomcat.apache.org/native-doc/"
# riscv64 blocked by java-jdk
arch="all !riscv64"
license="Apache-2.0"
options="!check" # package has no tests
makedepends="apr-dev chrpath java-jdk openssl1.1-compat-dev"
subpackages="$pkgname-dev"
source="https://archive.apache.org/dist/tomcat/tomcat-connectors/native/$pkgver/source/tomcat-native-$pkgver-src.tar.gz"
builddir="$srcdir/$pkgname-$pkgver-src/native"

build() {
	./configure --prefix=/usr \
		--with-apr=/usr/bin/apr-1-config \
		--with-java-home=/usr/lib/jvm/default-jvm \
		--with-ssl=yes
	make
}

package() {
	make DESTDIR="$pkgdir" install

	# Remove redundant rpath.
	chrpath --delete "$pkgdir"/usr/lib/libtcnative-1.so

	rm -f "$pkgdir"/usr/lib/libtcnative-1.la
}

dev() {
	default_dev
	mv "$subpkgdir"/usr/lib/libtcnative-1.so "$pkgdir"/usr/lib/
}

sha512sums="
b9ffe0ecfd14482ed8c752caf2c28d880ab5fca1f5ea1d5b2a8330d26a14266406bdecda714644603ba2d4ca78c22ec5fc2341afd09172d073f21cf5a1099a0f  tomcat-native-1.2.33-src.tar.gz
"
